home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Internet Tools 1993 July / Internet Tools.iso / RockRidge / ip / slip / cslip-2.6 / tip / tip.h < prev    next >
Encoding:
C/C++ Source or Header  |  1992-06-17  |  8.5 KB  |  306 lines

  1. /*
  2.  * Copyright (c) 1983 The Regents of the University of California.
  3.  * All rights reserved.
  4.  *
  5.  * Redistribution and use in source and binary forms are permitted
  6.  * provided that: (1) source distributions retain this entire copyright
  7.  * notice and comment, and (2) distributions including binaries display
  8.  * the following acknowledgement:  ``This product includes software
  9.  * developed by the University of California, Berkeley and its contributors''
  10.  * in the documentation or other materials provided with the distribution
  11.  * and in all advertising materials mentioning features or use of this
  12.  * software. Neither the name of the University nor the names of its
  13.  * contributors may be used to endorse or promote products derived
  14.  * from this software without specific prior written permission.
  15.  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
  16.  * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
  17.  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  18.  *
  19.  *    @(#)tip.h    5.5 (Berkeley) 6/1/90
  20.  */
  21.  
  22. /*
  23.  * tip - terminal interface program
  24.  */
  25.  
  26. #include <sys/types.h>
  27. #include <sys/file.h>
  28.  
  29. #include <sgtty.h>
  30. #include <signal.h>
  31. #include <stdio.h>
  32. #include <pwd.h>
  33. #include <ctype.h>
  34. #include <setjmp.h>
  35. #include <sys/errno.h>
  36. #include <netdb.h>
  37. #include <strings.h>
  38.  
  39. #if    defined(SUNOS4) || defined(__ANSI__) || defined(sparc)
  40. typedef void sigfunc_t;
  41. #else
  42. typedef int sigfunc_t;
  43. #endif
  44.  
  45. /*
  46.  * Remote host attributes
  47.  */
  48. char    *DV;            /* UNIX device(s) to open */
  49. char    *EL;            /* chars marking an EOL */
  50. char    *CM;            /* initial connection message */
  51. char    *IE;            /* EOT to expect on input */
  52. char    *OE;            /* EOT to send to complete FT */
  53. char    *CU;            /* call unit if making a phone call */
  54. char    *AT;            /* acu type */
  55. char    *PN;            /* phone number(s) */
  56. char    *DI;            /* disconnect string */
  57. char    *PA;            /* parity to be generated */
  58.  
  59. char    *PH;            /* phone number file */
  60. char    *RM;            /* remote file name */
  61. char    *HO;            /* host name */
  62.  
  63. char    *CC;            /* local shell command to execute after login */
  64. char    *SA;            /* local slip address */
  65. char    *DA;            /* destination slip address */
  66. char    *SM;            /* netmask for slip */
  67. char    *ST;            /* slip type */
  68. char    *LS;            /* login script file */
  69.  
  70. int    BR;            /* line speed for conversation */
  71. int    FS;            /* frame size for transfers */
  72.  
  73. char    DU;            /* this host is dialed up */
  74. char    HW;            /* this device is hardwired, see hunt.c */
  75. char    *ES;            /* escape character */
  76. char    *EX;            /* exceptions */
  77. char    *FO;            /* force (literal next) char*/
  78. char    *RC;            /* raise character */
  79. char    *RE;            /* script record file */
  80. char    *PR;            /* remote prompt */
  81. int    DL;            /* line delay for file transfers to remote */
  82. int    CL;            /* char delay for file transfers to remote */
  83. int    ET;            /* echocheck timeout */
  84. char    HD;            /* this host is half duplex - do local echo */
  85.  
  86. /*
  87.  * String value table
  88.  */
  89. typedef
  90.     struct {
  91.         char    *v_name;    /* whose name is it */
  92.         char    v_type;        /* for interpreting set's */
  93.         char    v_access;    /* protection of touchy ones */
  94.         char    *v_abrev;    /* possible abreviation */
  95.         char    *v_value;    /* casted to a union later */
  96.     }
  97.     value_t;
  98.  
  99. #define STRING    01        /* string valued */
  100. #define BOOL    02        /* true-false value */
  101. #define NUMBER    04        /* numeric value */
  102. #define CHAR    010        /* character value */
  103.  
  104. #define WRITE    01        /* write access to variable */
  105. #define    READ    02        /* read access */
  106.  
  107. #define CHANGED    01        /* low bit is used to show modification */
  108. #define PUBLIC    1        /* public access rights */
  109. #define PRIVATE    03        /* private to definer */
  110. #define ROOT    05        /* root defined */
  111.  
  112. #define    TRUE    1
  113. #define FALSE    0
  114.  
  115. #define ENVIRON    020        /* initialize out of the environment */
  116. #define IREMOTE    040        /* initialize out of remote structure */
  117. #define INIT    0100        /* static data space used for initialization */
  118. #define TMASK    017
  119.  
  120. /*
  121.  * Definition of ACU line description
  122.  */
  123. typedef
  124.     struct {
  125.         char    *acu_name;
  126.         int    (*acu_dialer)();
  127.         int    (*acu_disconnect)();
  128.         int    (*acu_abort)();
  129.     }
  130.     acu_t;
  131.  
  132. #define    equal(a, b)    (strcmp(a,b)==0)/* A nice function to string compare */
  133.  
  134. /*
  135.  * variable manipulation stuff --
  136.  *   if we defined the value entry in value_t, then we couldn't
  137.  *   initialize it in vars.c, so we cast it as needed to keep lint
  138.  *   happy.
  139.  */
  140. typedef
  141.     union {
  142.         int    zz_number;
  143.         short    zz_boolean[2];
  144.         char    zz_character[4];
  145.         int    *zz_address;
  146.     }
  147.     zzhack;
  148.  
  149. #define value(v)    vtable[v].v_value
  150.  
  151. #define number(v)    ((((zzhack *)(&(v))))->zz_number)
  152. #ifdef vax
  153. #define boolean(v)    ((((zzhack *)(&(v))))->zz_boolean[0])
  154. #define character(v)    ((((zzhack *)(&(v))))->zz_character[0])
  155. #else
  156. #define boolean(v)    ((((zzhack *)(&(v))))->zz_boolean[1])
  157. #define character(v)    ((((zzhack *)(&(v))))->zz_character[3])
  158. #endif
  159. #define address(v)    ((((zzhack *)(&(v))))->zz_address)
  160.  
  161. /*
  162.  * Escape command table definitions --
  163.  *   lookup in this table is performed when ``escapec'' is recognized
  164.  *   at the begining of a line (as defined by the eolmarks variable).
  165. */
  166.  
  167. typedef
  168.     struct {
  169.         char    e_char;        /* char to match on */
  170.         char    e_flags;    /* experimental, priviledged */
  171.         char    *e_help;    /* help string */
  172.         int     (*e_func)();    /* command */
  173.     }
  174.     esctable_t;
  175.  
  176. #define NORM    00        /* normal protection, execute anyone */
  177. #define EXP    01        /* experimental, mark it with a `*' on help */
  178. #define PRIV    02        /* priviledged, root execute only */
  179.  
  180. extern int    vflag;        /* verbose during reading of .tiprc file */
  181. extern value_t    vtable[];    /* variable table */
  182.  
  183. #ifndef ACULOG
  184. #define logent(a, b, c, d)
  185. #define loginit()
  186. #endif
  187.  
  188. /*
  189.  * Definition of indices into variable table so
  190.  *  value(DEFINE) turns into a static address.
  191.  */
  192.  
  193. #define BEAUTIFY    0
  194. #define BAUDRATE    1
  195. #define DIALTIMEOUT    2
  196. #define EOFREAD        3
  197. #define EOFWRITE    4
  198. #define EOL        5
  199. #define ESCAPE        6
  200. #define EXCEPTIONS    7
  201. #define FORCE        8
  202. #define FRAMESIZE    9
  203. #define HOST        10
  204. #define LOG        11
  205. #define PHONES        12
  206. #define PROMPT        13
  207. #define RAISE        14
  208. #define RAISECHAR    15
  209. #define RECORD        16
  210. #define REMOTE        17
  211. #define SCRIPT        18
  212. #define TABEXPAND    19
  213. #define VERBOSE        20
  214. #define SHELL        21
  215. #define HOME        22
  216. #define ECHOCHECK    23
  217. #define DISCONNECT    24
  218. #define TAND        25
  219. #define LDELAY        26
  220. #define CDELAY        27
  221. #define ETIMEOUT    28
  222. #define RAWFTP        29
  223. #define HALFDUPLEX    30
  224. #define    LECHO        31
  225. #define    PARITY        32
  226. #define    CONNECTCMD    33
  227. #define    SLIPADDR    34
  228. #define SLIPDSTADDR    35
  229. #define    SLIPMASK    36
  230. #define    SLIPTYPE    37
  231. #define LOGINSCRIPT    38
  232. #define LINESYNC        39
  233. #define DTRHUP        40
  234. #define HWFC        41
  235.  
  236. #define NOVAL    ((value_t *)NULL)
  237. #define NOACU    ((acu_t *)NULL)
  238. #define NOSTR    ((char *)NULL)
  239. #define NOFILE    ((FILE *)NULL)
  240. #define NOPWD    ((struct passwd *)0)
  241.  
  242. struct sgttyb    arg;        /* current mode of local terminal */
  243. struct sgttyb    defarg;        /* initial mode of local terminal */
  244. struct tchars    tchars;        /* current state of terminal */
  245. struct tchars    defchars;    /* initial state of terminal */
  246. struct ltchars    ltchars;    /* current local characters of terminal */
  247. struct ltchars    deflchars;    /* initial local characters of terminal */
  248.  
  249. FILE    *fscript;        /* FILE for scripting */
  250.  
  251. int    fildes[2];        /* file transfer synchronization channel */
  252. int    repdes[2];        /* read process sychronization channel */
  253. int    FD;            /* open file descriptor to remote host */
  254. int    AC;            /* open file descriptor to dialer (v831 only) */
  255. int    vflag;            /* print .tiprc initialization sequence */
  256. int    sfd;            /* for ~< operation */
  257. int    pid;            /* pid of tipout */
  258. uid_t    uid, euid;        /* real and effective user id's */
  259. gid_t    gid, egid;        /* real and effective group id's */
  260. int    stop;            /* stop transfer session flag */
  261. int    quit;            /* same; but on other end */
  262. int    intflag;        /* recognized interrupt */
  263. int    stoprompt;        /* for interrupting a prompt session */
  264. int    timedout;        /* ~> transfer timedout */
  265. int    cumode;            /* simulating the "cu" program */
  266. int    slip;            /* bring up SLIP on the line */
  267. int    debug;            /* debug flag used by some acu code */
  268.  
  269. char    fname[80];        /* file name buffer for ~< */
  270. char    copyname[80];        /* file name buffer for ~> */
  271. char    ccc;            /* synchronization character */
  272. char    ch;            /* for tipout */
  273. char    uucplock[];        /* name of lock file for uucp's */
  274.  
  275. int    odisc;                /* initial tty line discipline */
  276. extern    int disc;            /* current tty discpline */
  277.  
  278. extern    char *ctrl();
  279. extern    char *ctime();
  280. extern    long time();
  281. extern    struct passwd *getpwuid();
  282. extern    char *getlogin();
  283. extern    char *vinterp();
  284. extern    char *getenv();
  285. extern    char *rindex();
  286. extern    char *index();
  287. extern    char *malloc();
  288. extern    char *lconnect();
  289.  
  290. extern int errno;
  291.  
  292. #undef CTRL
  293. #define    CTRL(c)    ((c)&037)
  294.  
  295. #ifndef FD_SETSIZE
  296. /*
  297.  * The following is defined just in case someone should want to run
  298.  * this ftp on a 4.2 system.
  299.  *
  300.  */
  301. #define FD_SET(n, p)    ((p)->fds_bits[0] |= (1<<(n)))
  302. #define FD_CLR(n, p)    ((p)->fds_bits[0] &= ~(1<<(n)))
  303. #define FD_ISSET(n, p)    ((p)->fds_bits[0] & (1<<(n)))
  304. #define FD_ZERO(p)    ((p)->fds_bits[0] = 0)
  305. #endif
  306.